aux_source_directory(. SRC_LIST)

file(GLOB HEADERS "*.h")

eth_simple_add_executable(eth ${SRC_LIST} ${HEADERS})

find_package(Eth)
find_package(Web3)

target_include_directories(eth PRIVATE ..)
target_link_libraries(eth ${Eth_EVM_LIBRARIES})
target_link_libraries(eth ${Web3_WEB3JSONRPC_LIBRARIES})
target_link_libraries(eth ${Web3_WEBTHREE_LIBRARIES})
target_link_libraries(eth jsonrpc::client)


find_path(
    MHD_INCLUDE_DIR
    NAMES microhttpd.h
    DOC "microhttpd include dir"
)

find_library(
    MHD_LIBRARY
    NAMES libmicrohttpd microhttpd microhttpd-12
    DOC "microhttpd library"
)

set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
set(MHD_LIBRARIES ${MHD_LIBRARY})

# debug library on windows
# same naming convention as in qt (appending debug library with d)
# boost is using the same "hack" as us with "optimized" and "debug"
# official MHD project actually uses _d suffix

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(mhd DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY)
mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)

# TODO: Remove.
target_compile_definitions(eth PRIVATE ETH_JSONRPC)

if (EVMJIT)
	# Do we need include paths here?
	target_link_libraries(eth ${Eth_EVMJIT_LIBRARIES})
	eth_copy_dlls(eth EVMJIT_DLLS)
endif()

target_link_libraries(eth pthread)
target_link_libraries(eth /usr/lib/x86_64-linux-gnu/libmicrohttpd.so)
eth_install_executable(eth)
